/**
 * 
 */
package uk.co.cdal.cobweb.frontend.GUI;

import java.awt.BorderLayout;
import java.awt.Insets;

import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;

import uk.co.cdal.cobweb.frontend.GUI.actionlisteners.AddURLListener;
import uk.co.cdal.cobweb.frontend.GUI.actionlisteners.RemoveURLListener;

/**
 * @author seb
 *
 */
public class URLDisplay extends JPanel {
	
	private Insets emptyBorder = new Insets(0,0,0,0);
	
	public URLDisplay() {
		setLayout(new BorderLayout());
		JButton button = new JButton(new ImageIcon("icons/link_add.png"));
		button.addMouseListener(new AddURLListener());
		button.setEnabled(true);
		
		button.setToolTipText("Click here to attach a URL");
		button.setOpaque(false);
		button.setIconTextGap(0);
		button.setMargin(emptyBorder);
		button.setContentAreaFilled(false);
		button.setBorderPainted(false);
		button.setFocusPainted(false);
		
		add(button, BorderLayout.EAST);
	}

	public URLDisplay(String url) {
		
		setLayout(new BorderLayout());
		
		JButton button = new JButton(new ImageIcon("icons/link_delete.png"));
		button.addMouseListener(new RemoveURLListener());
		button.setEnabled(true);
		
		button.setToolTipText("Click here to attach a URL");
		button.setOpaque(false);
		button.setIconTextGap(0);
		button.setMargin(emptyBorder);
		button.setContentAreaFilled(false);
		button.setBorderPainted(false);
		button.setFocusPainted(false);
		
		add(button, BorderLayout.EAST);
		add(new JLabel(url), BorderLayout.CENTER);
		
	}
}
